home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 176-200 / scopedisk180 / rxmenu2 / exec1.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-19  |  4KB  |  136 lines

  1. /************************************************************************/
  2. /*                                Exec1                                 */
  3. /*                               =======                                */
  4. /*                                                                      */
  5. /* This EXEC will attempt to auto-execute a file based on its file-     */
  6. /* type.  Filetypes recognized are listed at the start of the exec.     */
  7. /* Can be included in another ARexx macro or called from one.           */
  8. /* This is special version for use with ArexxMenu.rexx.                 */
  9. /* Steven D. Kapplin                                          */
  10. /* 11/2/90                                                  */
  11. /************************************************************************/
  12.  
  13. trace off                                   /* Disable ARexx tracing    */
  14.  
  15. parse upper arg fname wind                  /* Get file name            */
  16.  
  17. if fname = '' then do                       /* No filename passed?      */
  18.     return 5
  19. end
  20.  
  21. /* Define some frequently used program names */
  22. /* Be sure to allow for space at end of name */
  23.  
  24. textviewer = "Run Sys:Tools/Type "
  25. pictureviewer = "Run Sys:Tools/Superview "
  26. unzoo = "c:archivers/Zoo "
  27. unarc = "c:archivers/Arc "
  28. unlzh = "c:archivers/LHarc "
  29. arcdir = "VD0:"
  30. playsound = "Run Sonica "
  31. player = "Run Dpaint:Play "
  32. editor = "sys:CEdit "
  33.  
  34. /* Define location of requestor at middle of screen */
  35.  
  36. /*  Filetype identifiers            */
  37.  
  38.     EXE = "F3"                /* Executable */
  39.     PIC = "494C424D424D4844"        /* IFF Picture File */
  40.     XCEL = "4654585450534554"    /* Excellence! File */
  41.     PROW = "574F5244464F4E54"    /* ProWrite File */
  42.     ADV = "04F404F404F404F4"        /* Advantage Worksheet */
  43.     MAXI = "474C424C"            /* MaxiPlan Worksheet */
  44.     CAND = "4445434B414E4E4F"    /* CanDo Deck */
  45.     SND = "3853565856484452"        /* 8SVX Sound File */
  46.     PPG = "0708090D"            /* Professional Page 1.3 File */
  47.     PGS = "07231988000D0200"        /* PageStream 1.8 File */
  48.     ANIM = "414E494D464F524D"    /* Anim File */
  49.     DYN = "44594350"            /* DigiPaint DYN */
  50.     LZH = ".LZH"                /* LHarc Archive */
  51.     ARC = ".ARC"                /* Arc Archive */
  52.     ZOO = ".ZOO"                /* Zoo Archive */
  53.     ZIP = ".ZIP"                /* PKaZip File (nothing yet implemented) */
  54.     RXX = ".REXX"                /* ARexx macro */
  55.     
  56.  
  57. /*----------------------------------*/
  58.  
  59. /* Open passed filename and read first 256 bytes */
  60.  
  61. call open(f,fname,'R')
  62. instring = c2x(readch(f,256))
  63. call close(f)
  64. result = 2
  65. select                                    /* Process file */
  66.     when substr(instring,217,8) = DYN then
  67.         cmd = 'Run Dyna-Show '
  68.     when substr(instring,7,2) = EXE then
  69.         cmd = 'Run '
  70.     when substr(instring,17,16) = PROW then
  71.         cmd = 'Run ProWrite:Prowrite '
  72.     when substr(instring,17,16) = PIC then
  73.         cmd = pictureviewer || '-c '
  74.     when substr(instring,17,16) = XCEL then
  75.         cmd = 'Run Excellence!:Excellence! '
  76.     when substr(instring,1,16) = ADV then
  77.         cmd = 'Run Advantage:Advantage '
  78.     when substr(instring,1,8) = MAXI then
  79.         cmd = 'Run MaxiPlan:MaxiPlan-III '
  80.     when substr(instring,17,16) = ANIM then
  81.         cmd = player
  82.     when substr(instring,17,16) = CAND then do
  83.         pragma('D','CanDo:')
  84.         cmd = 'Run DeckRunner'
  85.         end
  86.     when substr(instring,17,16) = SND then
  87.         cmd = playsound
  88.     when substr(instring,1,8) = PPG then
  89.         cmd = 'Run PPage:PPage'
  90.     when substr(instring,1,16) = PGS then
  91.         cmd = 'Run PageStream:PageStream '
  92.     when pos(ZIP,fname) > 0 then
  93.         cmd = "c:archivers/PKaZip "
  94.     when pos(RXX,fname) > 0 then
  95.         cmd = ""
  96.     when pos(LZH,fname) > 0 then do
  97.         pragma('D',arcdir)
  98.         result = MsgThree(wind,'Unarc or List?','Unarc=OK','List=NO')
  99.         if result = 1 then cmd = unlzh || "-a -m -x x "
  100.         else    cmd = unlzh || " l "
  101.         end
  102.     when pos(ARC,fname) > 0 then do
  103.         pragma('D',arcdir)
  104.         result = MsgThree(wind,'Unarc or List?','Unarc=OK','List=NO')
  105.         if result = 1 then cmd = unarc || "x "
  106.         else    cmd = unarc || " l "
  107.         end
  108.     when pos(ZOO,fname) > 0 then do
  109.         pragma('D',arcdir)
  110.         result = MsgThree(wind,'Unarc or List?','Unarc=OK','List=NO')
  111.         if result = 1 then cmd = unzoo || "e// "
  112.         else    cmd = unzoo || " l "
  113.         end
  114.     otherwise do
  115.         do i = 1 to 32 by 2 
  116.             s = substr(instring,i,2)
  117.             if  s ~= "0A" & s ~= "0D" & s < "20" | s > "7F" then do
  118.                 cmd = ""
  119.                 result = MsgOne(wind,"Don't Recognize File Type")
  120.                 return 5
  121.             end
  122.         end
  123.         result = MsgThree(wind,'Edit or View?','Edit=OK','View=NO')
  124.         if result = 1 then cmd = editor
  125.         else cmd = textviewer || " "
  126.         end
  127. end
  128.  
  129. if ~exists(fname || '.info') then cmd = 'runf1 'cmd''
  130.  
  131. address command cmd fname                /* Build command line */
  132.  
  133. return 0
  134.  
  135.  
  136.